/*Diego Lima de Freitas RA: 317632
 *Yuri Souza Padua RA: 317420
 * 
 * Classe que trata o comando while da liguagem
 */

package AST;

public class WhileCommand extends Command {

    private Expr expr;
    private Command command;

    public WhileCommand(Expr expr, Command command) {
        this.expr = expr;
        this.command = command;
    }

    @Override
    public void genC(PW pw) {

        pw.print("while ( ");
        expr.genC(pw, false);
        pw.out.println(" )");
        if (command instanceof CompositeCommand) {
            command.genC(pw);
        } else {
            pw.add();
            command.genC(pw);
            pw.sub();
        }
    }
}
